﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WL_WinForm
{
    public partial class FrmLogin : Form
    {
        public FrmLogin()
        {
            InitializeComponent();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        //登录
        private void btnLogin_Click(object sender, EventArgs e)
        {
            
            WLong.BLL.Rel_User user = new WLong.BLL.Rel_User();
            DataSet ds = user.GetList("UserName='" + txtUserName.Text.Trim() + "' and UserPassWord='" + COMMON.MD5.Encrypt(txtPassword.Text.Trim(), COMMON.MD5.md5Key) + "'");

            if (ds.Tables[0].Rows.Count > 0)
            {
                COMMON.Login.loginName = txtUserName.Text.Trim();
                FrmMain.startForm = true;
                this.Close();
            }
            else
            {
                COMMON.ControlCommon.ShowMessageBoxError("用户名或密码错误！");
            }
        }

        private void txtPassword_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                btnLogin_Click(null, null);
            }
        }
    }
}
